﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;

namespace ControleEstoque.PDA
{
	public partial class Login : Form
	{
		ControleEstoque.PDA.ControleEstoqueServices.ControleAtivoDataSet.UsuarioRow _currentUser;

		public Login()
		{
			InitializeComponent();
		}

        private void Login_KeyDown(object sender, KeyEventArgs e)
        {
            if ((e.KeyCode == System.Windows.Forms.Keys.Up))
            {
                // Up
            }
            if ((e.KeyCode == System.Windows.Forms.Keys.Down))
            {
                // Down
            }
            if ((e.KeyCode == System.Windows.Forms.Keys.Left))
            {
                // Left
            }
            if ((e.KeyCode == System.Windows.Forms.Keys.Right))
            {
                // Right
            }
            if ((e.KeyCode == System.Windows.Forms.Keys.Enter))
            {
                // Enter
            }

        }

		public ControleEstoque.PDA.ControleEstoqueServices.ControleAtivoDataSet.UsuarioRow CurrentUser
		{
			get
			{
				return _currentUser;
			}
		}

		private void btnEntrar_Click(object sender, EventArgs e)
		{
			ControleEstoque.PDA.ControleEstoqueServices.ControleAtivoDataSet.UsuarioDataTable result = Program.CurrentService.Usuario_VerificarUsuarioSenha(this.txtMatricula.Text, this.txtSenha.Text);

			if (result.Count > 0)
			{
				//Program.CurrentService.Credentials = new 
				_currentUser = result[0];
				this.DialogResult = DialogResult.OK;
			}
			else
			{
				MessageBox.Show("Matrícula ou senha inválidas.\r\nFavor tente novamente.", "Erro");
			}
		}
	}
}